package com.engr.springbooteasypoi.design.compisite;

import java.util.ArrayList;
import java.util.List;

/**
 * 树枝构件
 */
public class Composite extends Component {

    // 构件容器
    private List<Component> list = new ArrayList<>();

    //增加一个叶子构件或树枝构件
    public void add(Component component){
        list.add(component);
    }

    // 删除
    public void remove(Component component){
        list.remove(component);
    }

    // 获取分支下面所有叶子构件或者树枝构件
    public List<Component> getChildren(){
        return this.list;
    }
}
